package com.sc.mapper;

import com.sc.pojo.BookField;
import com.sc.pojo.Field;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface FieldMapper {
    //查询所有场地
    @Select("select * from field;")
    List<Field> selectAll();
    //添加场地
    @Insert("insert into field (fieldname,fieldincharge,fieldpicture,fieldinformation,fieldlocation,fieldstate) " +
            "values (#{fieldname},#{fieldincharge},#{fieldpicture},#{fieldinformation},#{fieldlocation},'空闲');")
    void addField(Field field);
    //根据id查找场地
    @Select("select * from field where fieldid=#{fieldid};")
     Field selectById(int fieldid);

    //更新场地信息
    void updateField (Field field);

    //根据id批量删除场地信息
    void deleteByIds(@Param("ids") int[] ids);

    //根据id删除场地信息
    @Delete("delete from field where fieldid=#{fieldid} ;")
    void deleteById( int fieldid);

    //查找状态为1的
    @Select("select * from field where showstate = 1;")
    List<Field> selectByShowState();
    
    //入场后修改场地状态
    @Update("update bookfield set orderstate = '已使用' where fieldbookid=#{fieldbookid};")
    void updateFieldState(BookField bookField);

    //退场后修改场地状态
    @Update("update bookfield set orderstate = '已退场' where fieldbookid=#{fieldbookid};")
    void updateFieldStateQuit(BookField bookField);


    //根据页码查询
    @Select("select * from field limit #{begin} , #{size};")
        List<Field> selectByPage(@Param("begin") int begin,@Param("size") int size);
    //查询所有记录
    @Select("select count(*) from field ;")
    int selectTotalCount();

}
